package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    @Select("select * from category order by sort")
    List<Category> findAll();

    @Delete("delete from category where id=#{id}")
    void deleteById(long id);

    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime} where id = #{id}")
    void updateById(Category category);

    List<Category> findByType(Integer type);

    @Select("select * from category where id=#{id}")
    Category findById(Long categoryId);
}
